package nina.yiyou.salary.process.global

import nina.yiyou.salary.input.util.InputPathResolver

import java.nio.file.Path
import java.time.LocalDate
import java.time.format.DateTimeFormatter

class GlobalMapProcessor {

  GlobalMapProcessor(Map globalMap, LocalDate salaryStartTime, LocalDate salaryEndTime, Path workshopPath) {
    _globalMap = globalMap
    _salaryStartTime = salaryStartTime
    _salaryEndTime = salaryEndTime
    _workshopPath = workshopPath
  }

  Map<String, ?> process() {
    def getStr = { String key -> _globalMap[key] as String }
    return [
        'out'  : new InputPathResolver(_workshopPath, getStr('out.工资')).resolve(),
        '工资时间始': _salaryStartTime.format(FMT),
        '工资时间终': _salaryEndTime.format(FMT),
    ]
  }

  private static final DateTimeFormatter FMT = DateTimeFormatter.ofPattern('yyyy.M.d')

  private final Map _globalMap

  private final LocalDate _salaryStartTime
  private final LocalDate _salaryEndTime

  private final Path _workshopPath
}
